﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OOS.Application.Order.Dtos;
using OOS.Application.Order.Services.Interfaces;
using OOS.Application.Order.Vos;
using OOS.Core.Order;
using OOS.Core.RelyOn;

namespace OOS.Application.Order
{
    /// <summary>
    /// 订单管理
    /// </summary>
    [Route("[Controller]")]
    public class OrderBasicAppService:IDynamicApiController
    {
        private readonly IOrderBasicService _orderBasicService;

        public OrderBasicAppService(IOrderBasicService orderBasicService)
        {
            _orderBasicService = orderBasicService;
        }

        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="orderBasic"></param>
        /// <returns></returns>
        [HttpPost]
        public Boolean AddOrderBasic(OrderBasic orderBasic)
        {
            return _orderBasicService.InsertOrderBasic(orderBasic);
        }

        /// <summary>
        /// 根据条件(订单号模糊查询，订单状态精确查询)分页查询
        /// </summary>
        /// <param name="searchOrderVo"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public PageResponseDto<List<OrderBasicDto>> GetOrderList(SearchOrderVo searchOrderVo, int pageIndex, int pageSize)
        {
            return _orderBasicService.SelectOrderPageByConditions(searchOrderVo, pageIndex, pageSize);
        }

        /// <summary>
        /// 根据id修改订单状态
        /// </summary>
        /// <param name="orderBasic"></param>
        /// <returns></returns>
        [HttpPut]
        public bool UpdateOrderBasic(OrderBasic orderBasic)
        {
            return _orderBasicService.UpdateOrderBasicById(orderBasic);
        }


        /// <summary>
        /// 根据id将数据库原始数据转化为详情数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public OrderBasicDto GetOrderBasic(int id)
        {
            return _orderBasicService.SelectOrderById(id);
        }
    }
}
